package cn.tta.controller.user;

import cn.tta.common.result.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController()
@RequestMapping("/user/shop")
@Slf4j
public class UserShopController {

    public static final String Key = "SHOP_STATUS";

    @Autowired
    private RedisTemplate redisTemplate;


    /**
     * 获取店铺的营业状态
     * @return
     */
    @GetMapping("/status")
    public Result getStatus() {
        Integer key = (Integer) redisTemplate.opsForValue().get(Key);
        log.info("用户获得店铺的营业状态：{}",key == 1 ? "营业" : "打样中");
        return Result.success(key);
    }
}
